<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('用户列表列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
<!--            <div class="col-sm-12 search-collapse">-->
<!--                <form id="formId">-->
<!--                    <div class="select-list">-->
<!--                        <ul>-->
<!--                            <li>-->
<!--                                <label>名称：</label>-->
<!--                                <input type="text" name="name"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>值：</label>-->
<!--                                <input type="text" name="value"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>：</label>-->
<!--                                <input type="text" name="pid"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>-->
<!--                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>-->
<!--                            </li>-->
<!--                        </ul>-->
<!--                    </div>-->
<!--                </form>-->
<!--            </div>-->

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="member:baseType:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="member:baseType:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="member:baseType:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="member:baseType:export">-->
<!--                    <i class="fa fa-download"></i> 导出-->
<!--                </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('member:baseType:edit')}]];
        var removeFlag = [[${@permission.hasPermi('member:baseType:remove')}]];
        var prefix = ctx + "member/baseType";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "用户列表",
                columns: [
                //     {
                //     checkbox: true
                // },
                {
                    field: 'id',
                    title: 'id'
                },
                // {
                //     field: 'type',
                //     title: '信息类型'
                // },
                {
                    field: 'name',
                    title: '名称'
                },
                {
                    field: 'value',
                    title: '值'
                },
                {
                    title: '状态',
                    formatter: function (value, row, index) {
                        return statusTools(row);
                    }
                },
                // {
                //     field: 'pid',
                //     title: ''
                // },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-info btn-xs " href="javascript:void(0)" onclick="detail(\'' + row.id+ '\' , \''+ row.name + '\')"><i class="fa fa-list-ul"></i>列表</a> ');
                        // actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });


        /* 用户状态显示 */
        function statusTools(row) {
            if (row.status == 0) {
                return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.id + '\')"></i> ';
            } else {
                return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.id + '\')"></i> ';
            }
        }

        /* 用户管理-停用 */
        function disable(id) {
            $.modal.confirm("确认要停用认证类型吗？", function() {
                $.operate.post(prefix + "/changeStatus", { "id": id, "status": 0 });
            })
        }

        /* 用户管理启用 */
        function enable(id) {
            $.modal.confirm("确认要启用认证类型吗？", function() {
                $.operate.post(prefix + "/changeStatus", { "id": id, "status": 1 });
            })
        }

        /*字典列表-详细*/
        function detail(id, name) {
            var url = prefix + '/detail/' + id;
            $.modal.openTab("类型-"+name, url);
        }

    </script>
</body>
</html>